home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3841 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.3 KB  |  43 lines

  1. Path: rain.fr!news
  2. From: Fabien Bergeret <fbergeret@nahua.arcanet.fr>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Random numbers in C++
  5. Date: Fri, 26 Jan 96 10:56:07 WET
  6. Organization: CSI InterNetNews site
  7. Message-ID: <NEWTNews.822653842.19085.fbergeret@nahua.arcanet.fr>
  8. References: <4e07ge$me7@server1.ctc.com>
  9. NNTP-Posting-Host: nahua.arcanet.fr
  10. Mime-Version: 1.0
  11. Content-Type: TEXT/PLAIN; charset=US-ASCII
  12. X-Newsreader: NEWTNews & Chameleon -- TCP/IP for MS Windows from NetManage
  13.  
  14.  
  15. In Article<4e07ge$me7@server1.ctc.com>, <kemp@ctc.com> write:
  16. > Path: alpha.rain.fr!rain.fr!news.sprintlink.net!news.localnet.com!ub!news.kei.com!newsfeed.internetmci.com!info.ucla.edu!CTCnet!ctc.com!usenet
  17. > From: Richard Kemp <kemp@ctc.com>
  18. > Newsgroups: comp.lang.c++
  19. > Subject: Random numbers in C++
  20. > Date: 22 Jan 1996 14:38:06 GMT
  21. > Organization: Concurrent Technologies Corporation (CTC)
  22. > Lines: 8
  23. > Message-ID: <4e07ge$me7@server1.ctc.com>
  24. > NNTP-Posting-Host: sgi19.ctc.com
  25. > Mime-Version: 1.0
  26. > Content-Type: text/plain; charset=us-ascii
  27. > Content-Transfer-Encoding: 7bit
  28. > X-Mailer: Mozilla 1.1S (X11; I; IRIX 5.3 IP22)
  29.  
  30. > How do you make a random number in C++. I'm not familiar with C, so if it's 
  31. a C
  32. > function that will help a lot also. Thanks!!
  33.  
  34. #include <stdlib.h>
  35. #include <time.h>
  36.  
  37. //Init
  38. random((unsigned)time(NULL));
  39.  
  40. //Use 
  41. a = srand()%the_number;
  42.  
  43.